package redis

import "strconv"

// 获取商品库存
func GetGoodsStock(goodsId int) int64 {

	key := "goods_stock:goods_id_" + strconv.Itoa(goodsId)
	return Rdb.LLen(key).Val()
}

// 扣除虚拟库存
func DecrGoodsStock(goodsId, stock int) {
	key := "goods_stock:goods_id_" + strconv.Itoa(goodsId)
	for i := 0; i < stock; i++ {
		Rdb.LPop(key)
	}
}
